package com.quanyan.ic.datacenter.dao.impl;

import com.quanyan.ic.datacenter.dao.EventAlarmDao;
import com.quanyan.ic.datacenter.dao.PlaceDao;
import com.quanyan.ic.datacenter.http.req.ReqEventAlarms;
import com.quanyan.ic.datacenter.http.resp.RespCategoryAlarms;
import com.quanyan.ic.datacenter.mapper.icData.EventAlarmMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;

import java.util.List;

/**
 * Created by jian.zhou on 2017/8/24.
 */
@Repository
public class EventAlarmDaoImpl implements EventAlarmDao {

    @Autowired
    private EventAlarmMapper eventAlarmMapper;

    @Autowired
    private PlaceDao placeDao;

    public List<RespCategoryAlarms> findPlaceCategory( ReqEventAlarms reqEventAlarms){
        Integer placeId = reqEventAlarms.getPlaceId();
        List<RespCategoryAlarms> listCa = placeDao.findPlaceCategory(placeId);
        List<RespCategoryAlarms> categoryAlarmsList =  eventAlarmMapper.findPlaceCategory(reqEventAlarms);
        for (RespCategoryAlarms respCategoryAlarms : listCa){
            for (RespCategoryAlarms rca : categoryAlarmsList ){
                if ( respCategoryAlarms.getCategoryId().intValue() == rca.getCategoryId().intValue()){
                    respCategoryAlarms.setCount(rca.getCount());
                }
            }
        }
        return listCa;
    }



}
